using System.Collections.Generic;
using System;
using MonoDevelop.Projects.Dom;

namespace MonoSharper
{
	
	
	public class Scopes
	{
		private SortedList<DomLocation, Scope> _ScopesByLocation = new SortedList<DomLocation, Scope>();
		public Scopes()
		{									
			
		}
		
		public Scope FindScope(DomLocation domLocation)
		{
			//NOTE: this should do but for debbuging could check the region too
			Scope lastScope = null;
			foreach(KeyValuePair<DomLocation, Scope> keysAndValues in _ScopesByLocation)
			{
				
				if(keysAndValues.Key > domLocation)
				{
					return lastScope;
				}
				lastScope = keysAndValues.Value;
			}
			
			return lastScope;
		}
		
	}
}
